package day15.Task;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Card {
    private String color;
    private String number;

    public Card() {
    }

    public Card(String color, String number) {
        this.color = color;
        this.number = number;
    }

    /**
     * 获取
     * @return color
     */
    public String getColor() {
        return color;
    }

    /**
     * 设置
     * @param color
     */
    public void setColor(String color) {
        this.color = color;
    }

    /**
     * 获取
     * @return number
     */
    public String getNumber() {
        return number;
    }

    /**
     * 设置
     * @param number
     */
    public void setNumber(String number) {
        this.number = number;
    }

    public String toString() {
        return  color + " " + number;
    }
}
class Main3{
    public static void main(String[] args) {
        List<Card> porker=createPoker();
        System.out.println("新牌"+porker);
        //洗牌
        Collections.shuffle(porker);
        System.out.println("洗牌后"+porker);
        List<List<Card>> players=dealCards(porker);
        for (List<Card> player : players) {
            System.out.println(player);
        }

    }
    public static List<List<Card>> dealCards(List<Card> porker){
        List<List<Card>> players=new ArrayList<>();
        List<Card> play1=new ArrayList<>();
        List<Card> play2=new ArrayList<>();
        List<Card> play3=new ArrayList<>();
        for(int i=0;i< 17;i++){
            play1.add(porker.remove(0));
            play2.add(porker.remove(0));
            play3.add(porker.remove(0));
        }
        players.add(play1);
        players.add(play2);
        players.add(play3);
        players.add(porker);
        return players;
    }
    public static  List<Card> createPoker(){
        List<Card> porker=new ArrayList<>();
        String[] numbers={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        String[] colors={"♥","♣","♠","♦"};
        for(String color:colors){
            for (String number : numbers) {
                porker.add(new Card(color,number));
            }
        }
        porker.add(new Card("黑色","14"));
        porker.add(new Card("红色","15"));
        return porker;
    }
}
